package com.cade.agriculturemall.view.register.registermycode;

import android.util.Log;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVMobilePhoneVerifyCallback;
import com.avos.avoscloud.AVUser;
import com.cade.agriculturemall.base.BasePresenter;

/**
 * Created by Lobby on 2017/11/16.
 */

public class RegisterMyCodePresenter extends BasePresenter<RegisterMyCodeContract.IView> implements RegisterMyCodeContract.IPresenter {
    public RegisterMyCodePresenter(RegisterMyCodeContract.IView view) {
        super(view);
    }

    @Override
    public void onResume() {

    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onDestroy() {

    }

    /**
     * 上传code若验证码验证成功，则进土mainActivaty；
     * 否则，判断是否重新认证
     * @param mobilePhone
     * @param password
     * @param code
     */

    @Override
    public void upCode(final String mobilePhone, String password, String code) {
        AVUser.verifyMobilePhoneInBackground(code, new AVMobilePhoneVerifyCallback() {
            @Override
            public void done(AVException e) {
                if (e == null) {
                    mView.showSuccess("验证成功");
                } else {
                    mView.showSuccess("验证失败,即将跳转至主页面");
                    Log.d("SMS", e.getMessage());
                }
                mView.redirection();
            }
        });
    }
}
